package com.htc.android.footprints.utils;

import android.content.Context;
import android.content.SharedPreferences;

public class SettingInfo
{
  private static SettingInfo instance = null;
  private int currentSerialNumber = 0;
  private String defSort = "create_time desc";
  private boolean firstLaunchFlag = true;
  private boolean firstRetrieveAddressFlag = true;
  private String listSort;
  private Context mContext;
  private SharedPreferences mSettingDb;
  public boolean retrieveAddress = true;
  public boolean showConnectionFailedAlert = true;
  public boolean showLocationDisabledAlert = true;

  private SettingInfo(Context paramContext)
  {
    init(paramContext);
  }

  public static void clear()
  {
    instance = null;
  }

  public static SettingInfo getInstance(Context paramContext)
  {
    if (instance == null)
      instance = new SettingInfo(paramContext);
    return instance;
  }

  private void init(Context paramContext)
  {
    this.mContext = paramContext;
    if (this.mSettingDb == null)
      this.mSettingDb = paramContext.getSharedPreferences("FootprintsSetting", 2);
    if (this.mSettingDb != null)
    {
      SharedPreferences.Editor localEditor = this.mSettingDb.edit();
      if (!this.mSettingDb.contains("pref_retrieve_address"))
        localEditor.putBoolean("pref_retrieve_address", true);
      if (!this.mSettingDb.contains("pref_show_location_disabled_alert"))
        localEditor.putBoolean("pref_show_location_disabled_alert", true);
      if (!this.mSettingDb.contains("pref_show_connection_failed_alert"))
        localEditor.putBoolean("pref_show_connection_failed_alert", true);
      if (!this.mSettingDb.contains("pref_serial_number"))
        localEditor.putInt("pref_serial_number", 0);
      if (!this.mSettingDb.contains("pref_list_sort"))
        localEditor.putString("pref_list_sort", this.defSort);
      localEditor.commit();
      this.retrieveAddress = this.mSettingDb.getBoolean("pref_retrieve_address", true);
      this.showLocationDisabledAlert = this.mSettingDb.getBoolean("pref_show_location_disabled_alert", true);
      this.showConnectionFailedAlert = this.mSettingDb.getBoolean("pref_show_connection_failed_alert", true);
      this.listSort = this.mSettingDb.getString("pref_list_sort", this.defSort);
    }
  }

  public int getCurrentSerialNumber()
  {
    return this.currentSerialNumber;
  }

  public int getNewSerialNumber()
  {
    int i = 0;
    if (this.mSettingDb == null)
      this.mSettingDb = this.mContext.getSharedPreferences("FootprintsSetting", 2);
    if ((this.mSettingDb != null) && (this.mSettingDb.contains("pref_serial_number")))
    {
      SharedPreferences.Editor localEditor = this.mSettingDb.edit();
      i = 1 + this.mSettingDb.getInt("pref_serial_number", 0);
      localEditor.putInt("pref_serial_number", i);
      localEditor.commit();
      this.currentSerialNumber = i;
    }
    return i;
  }

  public String getSortString()
  {
    String str = this.defSort;
    if (this.mSettingDb == null)
      this.mSettingDb = this.mContext.getSharedPreferences("FootprintsSetting", 2);
    if ((this.mSettingDb != null) && (this.mSettingDb.contains("pref_serial_number")))
    {
      SharedPreferences.Editor localEditor = this.mSettingDb.edit();
      str = this.mSettingDb.getString("pref_list_sort", this.defSort);
      localEditor.commit();
    }
    return str;
  }

  public boolean isFirstLaunch()
  {
    boolean bool = false;
    if (this.firstLaunchFlag)
    {
      if (this.mSettingDb == null)
        this.mSettingDb = this.mContext.getSharedPreferences("FootprintsSetting", 2);
      if (this.mSettingDb != null)
      {
        if (this.mSettingDb.contains("pref_is_first_launch"))
          break label82;
        SharedPreferences.Editor localEditor = this.mSettingDb.edit();
        localEditor.putBoolean("pref_is_first_launch", true);
        localEditor.commit();
      }
    }
    for (bool = true; ; bool = this.firstLaunchFlag)
    {
      return bool;
      label82: this.firstLaunchFlag = this.mSettingDb.getBoolean("pref_is_first_launch", false);
    }
  }

  public boolean isFirstRetrieveAddress()
  {
    boolean bool = false;
    if (this.firstRetrieveAddressFlag)
    {
      if (this.mSettingDb == null)
        this.mSettingDb = this.mContext.getSharedPreferences("FootprintsSetting", 2);
      if (this.mSettingDb != null)
      {
        if (this.mSettingDb.contains("pref_is_first_retrieve_address"))
          break label82;
        SharedPreferences.Editor localEditor = this.mSettingDb.edit();
        localEditor.putBoolean("pref_is_first_retrieve_address", true);
        localEditor.commit();
      }
    }
    for (bool = true; ; bool = this.firstRetrieveAddressFlag)
    {
      return bool;
      label82: this.firstRetrieveAddressFlag = this.mSettingDb.getBoolean("pref_is_first_retrieve_address", false);
    }
  }

  public void resetSerialNumber()
  {
    if (this.mSettingDb == null)
      this.mSettingDb = this.mContext.getSharedPreferences("FootprintsSetting", 2);
    if (this.mSettingDb != null)
    {
      SharedPreferences.Editor localEditor = this.mSettingDb.edit();
      localEditor.putInt("pref_serial_number", 0);
      localEditor.commit();
    }
  }

  public void setFirstLaunch(boolean paramBoolean)
  {
    this.firstLaunchFlag = paramBoolean;
    if (this.mSettingDb == null)
      this.mSettingDb = this.mContext.getSharedPreferences("FootprintsSetting", 2);
    if (this.mSettingDb != null)
    {
      SharedPreferences.Editor localEditor = this.mSettingDb.edit();
      localEditor.putBoolean("pref_is_first_launch", paramBoolean);
      localEditor.commit();
    }
  }

  public void setFirstRetrieveAddress(boolean paramBoolean)
  {
    this.firstRetrieveAddressFlag = paramBoolean;
    if (this.mSettingDb == null)
      this.mSettingDb = this.mContext.getSharedPreferences("FootprintsSetting", 2);
    if (this.mSettingDb != null)
    {
      SharedPreferences.Editor localEditor = this.mSettingDb.edit();
      localEditor.putBoolean("pref_is_first_retrieve_address", paramBoolean);
      localEditor.commit();
    }
  }

  public void setSortString(String paramString)
  {
    if (paramString != null)
    {
      if (this.mSettingDb == null)
        this.mSettingDb = this.mContext.getSharedPreferences("FootprintsSetting", 2);
      if (this.mSettingDb != null)
      {
        SharedPreferences.Editor localEditor = this.mSettingDb.edit();
        localEditor.putString("pref_list_sort", paramString);
        localEditor.commit();
      }
    }
  }
}

/* Location:           E:\workspace\dex2java\dex-translator-0.0.9.3\HtcFootprints_dex2jar.jar
 * Qualified Name:     com.htc.android.footprints.utils.SettingInfo
 * JD-Core Version:    0.6.0
 */